<?php
/**
 * 核心框架的入口文件
 */
/* 路径设置 */
define('HOME_PATH',ROOT_PATH.'/Home');
define('ADMIN_PATH',ROOT_PATH.'/Admin');
define('MOBILE_PATH',ROOT_PATH.'/Mobile');
define('CFG_PATH',ROOT_PATH.'/Config');
define('TEMP_PATH',ROOT_PATH.'/Temp');
define('HTML_PATH',ROOT_PATH.'/Static');
define('UPLOAD_PATH',ROOT_PATH.'/Uploads');
define('DEAULT_TPL','default');
define('LANG_PATH',CORE_PATH.'/Lang');
define('SUBDIR',str_replace('/notify.php','',$_SERVER['PHP_SELF']));
/* 日志文件 */

define('ADMIN_LOG',CORE_PATH.'/Log/admin_err.log');

/* 系统设置 */

define('SESSION_AUTO_START',true);//设置session_start


//error_reporting(E_ALL & ~E_NOTICE);
if(DEBUG==1)
{
	ini_set("display_errors", "On");
	error_reporting (E_ALL | E_STRICT);
}
if(DEBUG==0)
{
	error_reporting(0);
}
else 
{
	error_reporting(E_ALL & ~E_NOTICE);
	//error_reporting(0);
}

if(isset($_COOKIE['home_lang']))
{
	if($_COOKIE['home_lang']=='1')
	{
		//$default_lang="en-us";//默认语言
		define('DEFAULT_LANG',"en_us");
	}
	else
	{
		define('DEFAULT_LANG',"zh_cn");
		//$default_lang="zh-cn";//默认语言
	}

}
else
{
	define('DEFAULT_LANG',"zh_cn");
	// $default_lang="zh-cn";//默认语言
}
/* 伪静态开启*/
define('REWRITE',1);
/* 双语站设置 */
define('DIGLOSSIA',1);//双语站
define('CH_SC','<!--:zh-->');
define('EN_SC','<!--:en-->');
define('DIG_EC','<!--:-->');
/* 错误日志设置 */
define('ERROR_LOG',true);//是否开启错误记录
define('ERROR_PATH',ROOT_PATH.'/Temp/user_err.log');//用户级错误记录位置
require(CORE_PATH.'/Core/common.php');
define_request();
require(dirname(__FILE__)."/Routing/route.php");


function define_request()
{
	
	$request = isset($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:'';
	$group='';
	$action='';
	$module='';
	$parsed = explode('&' , $request);
	
	
	if(!empty($request))
	{
	    foreach ($parsed as $argument)
	   {
		
		list($variable , $value) = explode('=' , $argument);
		
		$getVars[$variable] = $value;
	   }
	}
	
	
	
	if(!isset($getVars['g'])&&!isset($getVars['m'])&&!isset($getVars['a']))
	{
		$getVars['g']='mobile';
		$getVars['m']='wxpay';
		$getVars['a']='notify';
	}

	if($getVars['g'])
	{
		$group='/'.ucfirst($getVars['g']);
	}
	else
	{
		$group='/Mobile';
	}
	
	if($getVars['m'])
	{
		$module="/Controller/".$getVars['m']."Controller.php";
	}
	else
	{
		hy_404();
	}
	if($getVars['a'])
	{
		$action=$getVars['a'];
	}

	define('GROUP_NAME', ucfirst($getVars['g']));	
	define('MODULE_NAME',$getVars['m']);
	define('ACTION_NAME',$getVars['a']);
	
}